package com.ruitu.router_module.util;

import android.content.Context;
import android.media.MediaPlayer;

//主要用来播放音乐
public class MediaUtil {
    public static MediaPlayer mediaplayer;

    public static void mediaPlay(int raw, Context context) {
        try {
            if (mediaplayer != null) {
                mediaplayer.stop();
                mediaplayer.release();
            }
            mediaplayer = MediaPlayer.create(context, raw);
            mediaplayer.start();
        } catch (Exception e) {

        }
    }

    public static void mediaStop() {
        try {
            if (mediaplayer != null) {
                mediaplayer.stop();
                mediaplayer.release();
                mediaplayer = null;
            }
        } catch (Exception e) {

        }
    }
}
